import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:xindong/common/xindong_sezhi.dart';
import 'package:xindong/manager/xindong_chat_singleton.dart';
import 'package:xindong/manager/xindong_page_singleton.dart';
import 'package:xindong/res/assets_res.dart';
import 'package:xindong/utils/xindong_image_util.dart';
import 'package:xindong/widgets/common/xindong_button.dart';
import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';

class XinDongLiaoTianMessageCallingBalance extends StatelessWidget {
  final V2TimMessage message;

  const XinDongLiaoTianMessageCallingBalance({Key? key, required this.message}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final isFromSelf = message.isSelf == true;
    final backgroundColor = isFromSelf ? Colors.grey.shade300 : Colors.white;

    return GetBuilder<XinDongChatSingleton>(
      builder: (controller) {
        return Container(
          padding: const EdgeInsets.all(10),
          decoration: BoxDecoration(color: backgroundColor, borderRadius: BorderRadius.circular(10)),
          child: Row(
            mainAxisSize: MainAxisSize.min,
            children: [
              ImageUtil.asset(AssetsRes.ICON_GOLD_COIN, width: 20, height: 20),
              const Text(
                " 余额不足",
                style: TextStyle(fontSize: 16, height: 1.2, color: DZColors.titleColor),
              ),
              if (isFromSelf)
                Container(
                  width: 44,
                  height: 24,
                  margin: const EdgeInsets.only(left: 8),
                  child: XinDongCommonButton(
                    "充值",
                    padding: const EdgeInsets.only(left: 8, right: 8),
                    textStyle: const TextStyle(fontSize: 13, height: 1.2, color: Colors.white),
                    onTap: () => XinDongPageSingleton.instance.toRechargeYeMian(),
                  ),
                ),
            ],
          ),
        );
      },
    );
  }
}
